package com.rtx.wms.customer.grp.upload.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rtx.wms.customer.grp.upload.GRPUploadService;
import com.rtx.wms.std.common.bean.WmsConstant;
import com.rtx.wms.std.qc.bean.RtxQcapply;
import com.rtx.wms.std.so.bean.ApiOrdersfinish;

/**
 * 复检申请
 */
@Primary
@Component("GrpQcapplyUpload")
public class GrpQcapplyUpload extends GRPUploadService{

	Logger log = LoggerFactory.getLogger(this.getClass());
	
	@Override
	protected String resolveCallBackAPICode(Object data) {
		return "GrpQcapplyUpload";
	}

	
	@Override
	protected void resolveResonse(String response, Object data) {
		RtxQcapply finish = (RtxQcapply) data;
		try {
			JSONObject res = JSON.parseObject(response,JSONObject.class);
			String code = res.getString("code");
			if(!"200".equals(code)) {
				finish.setRtxeditflagErp(WmsConstant.FAIL_FLAG);
				finish.setRtxeditflag(WmsConstant.FAIL_FLAG);
				finish.setRtxmsgErp(res.getString("message"));
			}else {
				finish.setRtxeditflagErp(WmsConstant.SUCCESS_FLAG);
				finish.setRtxeditflag(WmsConstant.SUCCESS_FLAG);
				finish.setRtxmsgErp(res.getString("message"));
			}
		} catch (Exception e) {
			log.error("",e);
			finish.setRtxeditflagErp(WmsConstant.FAIL_FLAG);
			finish.setRtxeditflag(WmsConstant.FAIL_FLAG);
			finish.setRtxmsgErp(e.getMessage());
		}
	}
}
